package com.price.sample.http.service

import com.price.httplib.base.BaseHttpApiService
import com.price.httplib.ssl.SSLHostnameVerifier
import com.price.httplib.ssl.SSLSocketFactoryCompat
import com.price.sample.http.myinterface.ExceptionApi
import okhttp3.Interceptor
import okhttp3.OkHttpClient


/**
 * Rename XXX  Service
 *
 */
object ExceptionApiService : BaseHttpApiService() {

    override fun getServiceUrl(): String? {
        return "https://www.wanandroid.com/"
    }
    override fun getInterceptor(): List<Interceptor>? {
        return null
    }

    /**
     * 再次封装一次，减少调用的代码量
     *
     */
    fun getService(): ExceptionApi {
        return getService(ExceptionApi::class.java)
    }

    override fun okHttpOtherSet(okHttpBuilder: OkHttpClient.Builder): OkHttpClient.Builder {
        val sslSocketFactory = SSLSocketFactoryCompat()
        okHttpBuilder.hostnameVerifier(SSLHostnameVerifier())
            .sslSocketFactory(sslSocketFactory, sslSocketFactory.MyTrustManager())
        return okHttpBuilder
    }
}